﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ASPItalia.ModelVirtualCasting.Messaging;

namespace ASPItalia.ModelVirtualCasting.Web.Utils
{
    public class SendErrorMail : IExceptionFilter
    {
        public void OnException(ExceptionContext filterContext)
        {
            EmailMessage email = new EmailMessage
            {
                From = "mvcdemoapp@aspitalia.local",
                To = "errors@aspitalia.local",
                Body = filterContext.Exception.ToString(),
                Subject = string.Format("Exception: {0} - {1}", 
                    DateTime.Now.ToString(),
                    filterContext.Exception.GetType().Name)
            };

            Messenger messageService = new Messenger(email);
            //messageService.SendEmailMessage();
        }
    }
}